/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2021-01-05
*/
package com.rzico.article.service;

import com.rzico.base.BaseMapper;
import com.rzico.base.CommResult;
import com.rzico.base.impl.BaseServiceImpl;
import com.rzico.article.entity.ArticleReview;
import com.rzico.basics.entity.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rzico.article.mapper.ArticleReviewMapper;

import java.util.Date;
import java.util.List;

/**
 * <pre>
 * 笔记评论业务类
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Service
public class ArticleReviewService extends BaseServiceImpl<ArticleReview, String> {

    @Autowired
    private ArticleReviewMapper articleReviewMapper;

    @Override
    public BaseMapper<ArticleReview, String> getMapper() {
        return articleReviewMapper;
    }

    public List<Long> selectMemberIdByArticleReviewIds(List<String> idsList) {
        return articleReviewMapper.selectMemberIdByArticleReviewIds(idsList);
    }

    public ArticleReview save(Member current, ArticleReview articleReview) {

        articleReview.setMemberId(current.getId());
        Date date = new Date();
        articleReview.setCreateDate(date);
        articleReview.setModifyDate(date);
        articleReview.setAvatar(current.getAvatar());
        articleReview.setNickname(current.getSysUser().getNickname());
        int affectCount = super.insert(articleReview);
        if (affectCount <= 0) {
            return null;
        }
        return articleReview;
    }
}
